int in =0 ;  
int i=0;

void setup() {
  pinMode(9,OUTPUT);//D9 door lock mechanism
  pinMode(10,OUTPUT); //D10 lamp notification
  pinMode(11,INPUT); //D11 door status sensor
  Serial.begin(9600);    
}

void loop() {
        int sensorValue = digitalRead(11);//read D11 the door closed or not
        
        if (Serial.available() > 0) {
                
                in = Serial.read();
                 

                
                Serial.print("Command: ");
                Serial.println(in,DEC);
                
  if(sensorValue == 1) {            
  switch (in) {
    case 76://case Lock
      
      digitalWrite (9, HIGH);
      delay(100);
      digitalWrite (10, HIGH);
      delay(1000);
      
      digitalWrite (10, LOW);
      delay(1000);
      break;
      
    case 85://case Unlock
      
      digitalWrite (9, LOW);
      delay(100);
     digitalWrite (10, HIGH);
      delay(1000);
      
      digitalWrite (10, LOW);
      delay(1000);
      
      digitalWrite (10, HIGH);
      delay(1000);
      
      digitalWrite (10, LOW);
      delay(1000);
      
      break;
      
    
      break;  
  }
  }
                
  }

}

